import { EntityModel } from '@midwayjs/orm';
import { Column, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { UserEntity } from './user';
import { GroupEntity } from './group';

@EntityModel({
  name: 'group_msg',
})
export class GroupMsgEntity {
  @PrimaryGeneratedColumn({
    type: 'bigint',
    comment: '主键id',
  })
  id: number;

  @Column({
    type: 'bigint',
    name: 'group_id',
    comment: '群人id',
  })
  groupId: number;

  @Column({
    type: 'bigint',
    name: 'user_id',
    nullable: false, // 不能为null
    comment: '群成员用户id',
  })
  userId: number;

  @Column({
    type: 'varchar',
    nullable: false, // 不能为null
    comment: '消息',
  })
  content: string;

  @Column({
    type: 'int',
    nullable: false, // 不能为null
    comment: '消息类型',
  })
  status: number;

  @Column({
    type: 'varchar',
    name: 'time',
    nullable: false, // 不能为null
    comment: '消息发送时间',
  })
  time: string;

  @ManyToOne(type => UserEntity)
  @JoinColumn({
    name: 'user_id',
  })
  users: UserEntity;

  @ManyToOne(type => GroupEntity)
  @JoinColumn({
    name: 'group_id',
  })
  groups: GroupEntity;
}
